{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "vscode": {
     "languageId": "plaintext"
    }
   },
   "outputs": [],
   "source": [
    "    @patch('os.listdir')\n",
    "    @patch('skimage.io.imread')\n",
    "    @patch('builtins.open')\n",
    "    def setUp(self, mock_open, mock_imread, mock_listdir):\n",
    "        # 假装的图像数据，用于模拟 imread 返回值\n",
    "        dummy_image = np.random.randint(0, 255, (20, 20), dtype=np.uint8)\n",
    "\n",
    "        # 模拟目录结构和文件\n",
    "        mock_listdir.return_value = ['test_image.png']\n",
    "        \n",
    "        # 模拟 imread 的行为，返回假设的图像数据\n",
    "        mock_imread.return_value = dummy_image\n",
    "\n",
    "        # 模拟打开标注文件，返回虚拟的标注行\n",
    "        mock_open.return_value.__enter__.return_value.readlines.return_value = [\n",
    "            '0 0 10 10 test_word'\n",
    "        ]\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
